<?php

namespace Controller\Single;

class Detail extends Base {

	public function actionIndex() {
		$this->setCurrentMenuKey('Single');
		$this->setLevelCategories();
		$params = $this->getRouteParams();
		$articleId = !empty($params[0]) ? (int) $params[0] : 0;
		if (!$articleId) {
			$this->throwException('参数错误');
		}
		$detail = \Business\Article::instance()->getDetailById($articleId);
		if (!$detail) {
			$this->throwException('没找到');
		}
		$userId = $detail['UserId'];
		$userInfo = \Business\User::instance()->getUserDetailInfo($userId);

		$otherArticles = \Business\Article::instance()->getUserOtherArticles($userId, $articleId, 5);
		$this->assign('detail', $detail);
		$this->assign('otherArticles', $otherArticles);
		$this->assign('userInfo', $userInfo);
		$this->display();
	}
}